<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Vue中的列表过渡</title>
  <script src="../asset/js/vue.js"></script>
  <style>
    .v-enter,
    .v-leave-to {
      opacity: 0;
    }

    .v-enter-active,
    .v-leave-active {
      transition: opacity 1s;
    }
  </style>
</head>

<body>
  <div id="root">
    <button @click='handleBtnClick'>Add</button>
    <transition-group>
      <div v-for='(item,index) of list' :key='item.id'>{{item.title}}</div>
    </transition-group>
  </div>
  <script>
    let count = 0
    let vm = new Vue({
      el: '#root',
      data: {
        list: []
      },
      methods: {
        handleBtnClick() {
          this.list.push({
            id: count++,
            title: `hello world --- ${count}`
          })
        }
      }
    })
  </script>
</body>

</html>